# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Sirat18 <aur@sirat18.de>
# Contributor: Paolo Giangrandi <peoro.noob@gmail.com>

pkgname=impacket
pkgver=0.9.24
pkgrel=3
pkgdesc='Collection of classes for working with network protocols'
url='https://github.com/CoreSecurity/impacket'
arch=('any')
license=('Apache')
depends=('python' 'python-pycryptodome' 'python-pycryptodomex' 'python-pyasn1'
         'python-pcapy' 'python-pyopenssl' 'python-six' 'python-ldap3' 'python-flask'
         'python-setuptools') # https://github.com/fortra/impacket/issues/885#issuecomment-1197218746
checkdepends=('python-pytest' 'python-pytest-runner' 'python-cryptography')
source=(https://github.com/CoreSecurity/impacket/archive/impacket_${pkgver//./_}.tar.gz)
sha256sums=('da3a6ff23122576d805d6841561f7de8a3edbd9e706a5acdb156d12982cae099')
sha512sums=('4e5ca6554353c0e6d73ba9feaf93338961862cc17d176fdf7cf734306a385ecadf1febbd06cf1ddbd179de8941b52768678dbf3f86c106a27f0992aa002305c0')

prepare() {
  cd ${pkgname}-${pkgname}_${pkgver//./_}
  sed -e '/test_smb.py/d' \
    -e '/test_nmb.py/d' \
    -e '/test_ntlm.py/d' \
    -e '/test_ldap.py/d' \
    -e '/rundce.sh/d' \
    -i tests/runall.sh
}

build() {
  cd ${pkgname}-${pkgname}_${pkgver//./_}
  python setup.py build
}

check() {
  cd ${pkgname}-${pkgname}_${pkgver//./_}/tests
  ./runall.sh
}

package() {
  cd ${pkgname}-${pkgname}_${pkgver//./_}
  python setup.py install -O1 --root="${pkgdir}" --skip-build
  install -Dm 644 ChangeLog.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  local PYTHONVERSION="$(python -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')"
  ln -s "/usr/lib/python${PYTHONVERSION}/site-packages/impacket/examples" "${pkgdir}/usr/share/doc/${pkgname}/examples"
}

# vim: ts=2 sw=2 et:
